import org.junit.Test;

import java.util.function.Supplier;

public class SupplierTest {
    @Test
    public void test1() throws Exception {
        Base b1 = new Base();
        Supplier<String> s1 = new Supplier<>() {
            @Override
            public String get() {
                return b1.getName();
            }
        };
        System.out.println(s1.get());
    }

    @Test
    public void test2() throws Exception {
        Base b2 = new Base("rose", 18);
//        Supplier<String> s2 = () -> b2.getName();
        Supplier<String> s2 = () -> b2.getName();
        System.out.println(s2.get());
    }

    @Test
    public void test3() throws Exception {
        Base b3 = new Base("tom", 22);
        Supplier<String> s3 = b3::getName;
        System.out.println(s3.get());
    }

    @Test
    public void test4() throws Exception {
        Base b4 = new Base("jax", 32);
        Supplier<Boolean> s4 = Base::showBase;
        System.out.println(s4.get());
    }
}
